#include<cstdio>
#include<vector>
using namespace std;
vector<int>ve[200011];
int h[200010],v[200011],n,f[1000001],s[1000001],b[200011][4],s2[1000001];
int main()
{
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&v[i]);
	int cnt=0,sum=1;
	s[1]=1;
	for(int i=2;i<=n;i++)
	{
		if(v[i]!=v[i-1])
		{
			b[++cnt][0]=sum;
			b[cnt][1]=v[i-1];
			b[cnt][2]=b[cnt-1][0];
			sum=0;
		 }
		s[i]=cnt+1;
		sum++;
	 } 
	b[++cnt][0]=sum;
	b[cnt][1]=v[n];
	b[cnt][2]=b[cnt-1][0];
	b[1][2]=b[2][2]=0x3f3f3f3f;
	b[1][2]=b[2][2]=0x3f3f3f3f;
	for(int i=1;i<=n;i++)
	{
		if(s[i]!=s[i-1])
			s2[i]=1;
		else
			s2[i]=s2[i-1]+1;
	 } 
	int maxn=0;
	for(int i=1;i<=n;i++)
	{
		if(s2[i]-1==b[s[i]][2])
			f[i]=f[i-(s2[i]+b[s[i]][2])]+1;
		else
		{
			if(s2[i]==1)f[i]=1;
			else f[i]=f[i-1]+1;
		}
		ve[f[i]].push_back(i);
		maxn=max(maxn,f[i]);
	}
	for(int i=1;i<=maxn;i++)
	{
		for(int j=0;j<ve[i].size();j++)
			printf("%d ",ve[i][j]);
		printf("\n");
	 } 
}
